#ifndef __CHASH_TABLE_H__
#define __CHASH_TABLE_H__

#include "cocos2d.h"

using namespace cocos2d;

typedef struct tagNode
{
	char *m_pKey;
	char *m_pValue;
	CCObject *m_pObject;
	bool m_bObjVal;
	bool m_bCopied;
	struct tagNode *m_pNext;
} Node;
typedef Node* LinkedList;

class CHashTable
{
public:
	CHashTable(int nSize);
	~CHashTable(void);

protected:
	LinkedList *m_pTable;
	int m_nSize;
	int m_nEntries;

	Node*	CreateNode(char *pKey, char *pVal, bool bCopy);
	Node*	CreateNode(char *pKey, CCObject *pObj, bool bKeyCopy);

public:
	void	Clear(void);
	int		GetHashValue (char *pKey, int nSize);
	void	Add(char *pKey, char *pVal, bool bCopy);
	void	Add(char *pKey, CCObject *pObj, bool bKeyCopy);
	char*	Get(char *pKey);
	CCObject* GetObj(char *pKey);
	void	Remove(char *pKey);
	void	Expand(void);
};

#endif  // __CHASH_TABLE_H__